<template>
	<view>
		<button @click="getdata">123</button>
		{{catedata}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				catedata:[],
				oldcatedata:[]
			}
		},
		onLoad() {
			getdata()
		},
		methods: {
			getdata(){
				let newcatedata = [] 
				this.oldcatedata.forEach((level1,index1)=>{
					level1.children.forEach((level2,index2)=>{
						if(level2.cat_level==1){
							level2.children.forEach((level3,index3)=>{
									newcatedata.push(level3)
								//level2.children.splice(index3, 1);
								})
								level2.children = []
								newcatedata.push(level2)
							//level1.children.splice(index2, 1);
						}
						else{ newcatedata.push(level2) }
					})
					level1.children = []
					newcatedata.push(level1)
				})
				this.catedata = newcatedata
			},
		}
	}
</script>

<style>

</style>
